package cc.bookcloud.tool.ocr.common.upload;


import lombok.Data;

@Data
public class FileMeta {

    // 存储路径
    private String storePath;
    // 原始文件名称
    private String originName;
    // 文件类型
    private String contentType;

    // 文件大小
    private Long fileSize;
    // 访问路径
    private String accessPath = "/oss/download?file=";



    public String encrypt() {
        StringBuffer buff = new StringBuffer();
        buff.append(storePath).append("~~");
        buff.append(originName).append("~~");
        buff.append(contentType).append("~~");
        buff.append(fileSize).append("~~");
        return null;
    }

    public FileMeta decrypt(String enParamsStr) {
        String enStr = enParamsStr.toLowerCase();
        String deStr = null;
        initProp(deStr);
        return this;
    }

    // 文件存在路径||原始文件名称||文件类型||文件大小
    private FileMeta initProp(String meta) {
        String[] metas = meta.split("~~");
        this.storePath = metas[0];
        this.originName = metas[1];
        this.contentType = metas[2];
        this.fileSize = Long.valueOf(metas[3]);
        return this;
    }


    public static FileMeta build() {
        return new FileMeta();
    }

    public FileMeta storePath(String storePath) {
        this.storePath = storePath;
        return this;
    }

    public FileMeta originName(String originName) {
        this.originName = originName;
        return this;
    }

    public FileMeta contentType(String contentType) {
        this.contentType = contentType;
        return this;
    }

    public FileMeta fileSize(Long fileSize) {
        this.fileSize = fileSize;
        return this;
    }

    public FileMeta accessPath(String accessPath) {
        this.accessPath = accessPath;
        return this;
    }


    public String getStorePath() {
        return storePath;
    }

    public String getOriginName() {
        return originName;
    }


    public String getContentType() {
        return contentType;
    }


    public Long getFileSize() {
        return fileSize;
    }

    public String getAccessPath() {
        return accessPath;
    }
}
